#include <iostream>
using namespace std;

int arr[100005], tmp[100005];

long long merge_sort(int *arr, int left, int right)
{
    if(left >= right) return 0;
    
    int l = left, mid = (left + right) / 2, r = mid + 1, cur = left;
    long long ans_left = merge_sort(arr, left, mid), ans_right = merge_sort(arr, mid + 1, right), ans_cur = 0;
    while(l <= mid && r <= right)
        if(arr[l] <= arr[r]) tmp[cur++] = arr[l++];
        else
        {
            ans_cur += mid - l + 1;
            tmp[cur++] = arr[r++];
        }
    while(l <= mid) tmp[cur++] = arr[l++];
    while(r <= right) tmp[cur++] = arr[r++];
    
    for(int i = left; i <= right; ++i) arr[i] = tmp[i];
    
    return ans_cur + ans_right + ans_left;
}

int main()
{
    int n; cin >> n;
    for(int i = 0; i < n; ++i) cin >> arr[i];
    cout << merge_sort(arr, 0, n - 1);
    return 0;
}